package com.thirteenClassicsServer.mapper;

import java.time.LocalDateTime;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.github.pagehelper.Page;
import com.thirteenClassics.dto.BookPageQueryDTO;
import com.thirteenClassics.entity.Book;

@Mapper
public interface BookMapper {


    Page<Book> pageQuery(BookPageQueryDTO bookPageQueryDTO);

    void insert(Book book);

    @Update("update book set create_flag=1 where id=#{bookid}")
    void updateFlag(Long bookid);

    @Delete("delete from book where id = #{id}")
    void deleteById(Long id);

    void update(Book book);

    @Select("select * from book where id= #{id}")
    Book selectbookById(Long id);

    @Select("select * from book where book_name= #{bookName} and book_lang= #{bookLang} and version= #{version}")
    List<Book> selectbook(Book book);

    @Select("select * from book where book_name= #{bookName}")
    List<Book> selectbookJdb(Book book);

    Book selectbookByEntryId(Long entryId);

    Book selectMinorityBookByEntryId(Long entryId);

    @Select("select id from book where book_name=#{bookName} and jdb_flag=1 and create_flag=1")
    Long selectJdbBookIdByName(String bookName);

    @Update("update book set book_entry_time=#{time}, book_entry_name=#{username} where id=#{id}")
    void updateEntryTimeAndName(@Param("id") Long id, @Param("time") LocalDateTime time,
            @Param("username") String username);

    @Update("update book set book_mark_time=#{time}, book_mark_name =#{username} where id=#{id}")
    void updateMarkTime(@Param("id") Long id, @Param("time") LocalDateTime time, @Param("username") String username);

}
